Package de.yaams.maker.helper.gui.form

Source Code of de.yaams.maker.helper.gui.form.FormLink

/**
*
*/
package de.yaams.maker.helper.gui.form;

import java.awt.event.ActionEvent;

import org.jdesktop.swingx.JXHyperlink;
import org.jdesktop.swingx.hyperlink.AbstractHyperlinkAction;

import de.yaams.maker.helper.SystemHelper;

/**
* @author Nebli
*
*/
public class FormLink extends FormElement {

  protected JXHyperlink link;

  /**
   * @param title
   */
  public FormLink(final String content, final String url) {
    super("");
    if (content != null) {
      // final String s = content.toString();

      AbstractHyperlinkAction<Object> linkAction = new AbstractHyperlinkAction<Object>(content) {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
          SystemHelper.openUrl(content);
          setVisited(true);
        }
      };
      link = new JXHyperlink(linkAction);
    }
    element = link;
  }

  /*
   * (non-Javadoc)
   *
   * @see de.yaams.packandgo.helper.gui.form.FormElement#getContentAsString()
   */
  @Override
  public String getContentAsString() {
    return link != null ? link.getText() : null;
  }

  /*
   * (non-Javadoc)
   *
   * @see
   * de.yaams.packandgo.helper.gui.form.FormElement#setContent(java.lang.String
   * )
   */
  @Override
  public void setContent(String newcontent) {
    if (link != null) {
      link.setText(newcontent);
    }
  }

}
TOP

Related Classes of de.yaams.maker.helper.gui.form.FormLink

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.